package org.fatmansoft.teach.repository;

import org.fatmansoft.teach.models.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface StudentHonorRepository extends JpaRepository<StudentHonor,Integer> {
    //用于主键自增
    @Query(value = "select max(studentHonorId) from StudentHonor ")
    Integer getMaxId();

    @Query(value = "from StudentHonor where ?1='' or title like %?1% or level like %?1%")
    List<StudentHonor> findHonorListByTitleLevel(String titleLevel);

    Optional<StudentHonor> findByTitle(String title);

    void deleteByTitle(String title);

    void deleteByTitleAndDate(String title, String date);

    Optional<StudentHonor> findByTitleAndDate(String title, String date);

}
